<?php

class RootPath
{

    /**
     * 初始化根目录路径
     * @param string $rootPath 根目录路径
     */
    public static function getRootPath()
    {
        $uri = $_SERVER['REQUEST_URI'];
        $projectName = explode('/', trim($uri, '/'))[0]; // 假设项目名是 URL 的第一个部分
        $dir = $_SERVER['DOCUMENT_ROOT'];
        $rootPath = $dir . "/" . $projectName;
        return $rootPath;
    }

    public static function importPath($path)
    {
        $rootPath = self::getRootPath();
        include $rootPath."/". $path;
        //return $rootPath."/". $path;
    }

    public static function getPath($projectPath)
    {
        $rootPath = self::getRootPath();
        return $rootPath."/". $projectPath;
    }



}
